
#include "Singleton.h"

Instance::Instance()
{
	InstanceManager::getInstance().add(this);
}

Instance::~Instance()
{

}

InstanceManager::~InstanceManager()
{
	clear();
}

void InstanceManager::add(Instance *pInstance)
{
	InstancePtr pIn(pInstance);
	m_intances.push_back(pIn);
}

void InstanceManager::clear()
{
	for (auto iter = m_intances.rbegin(), iterEnd = m_intances.rend(); iter != iterEnd; ++iter)
	{
		InstancePtr pIns;
		(*iter).swap(pIns);
	}
	m_intances.clear();
}

std::unique_ptr<InstanceManager> InstanceManager::s_pInstance;